using OracleInternal.Json.Binary;
using OracleInternal.Json.Common;

namespace OracleInternal.Json.Sql
{
	internal class OracleJsonString : OracleJsonValue
	{
		private char[] m_value;

		private int strLen;

		internal OracleJsonString(char[] value)
		{
			m_value = value;
			strLen = value.Length;
		}

		internal OracleJsonString(char[] value, int length)
		{
			m_value = value;
			strLen = length;
		}

		internal string GetJsonString()
		{
			return new string(m_value, 0, m_value.Length);
		}

		internal int GetStringLen()
		{
			return strLen;
		}

		internal char[] GetCharArrRep()
		{
			return m_value;
		}

		public override OracleJsonType GetOracleJsonType()
		{
			return OracleJsonType.STRING;
		}

		public override string ToJsonString()
		{
			return OracleJsonSerializer.SerializeString(GetJsonString());
		}

		protected IExceptionFactory GetExceptionFactory()
		{
			return OracleJsonExceptions.ORACLE_FACTORY;
		}
	}
}
